

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>feature</title>
		<meta name="keywords" content="">
		<meta name="description" content="">
		<link rel="shortcut icon" href="../favicon.ico">
		<link href="../../css/bootstrap.min-lumen.css" rel="stylesheet">
		<link href="../../css/font-awesome.css?v=4.4.0" rel="stylesheet">
		<link href="../../css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
		<link href="../../css/animate.css" rel="stylesheet">
		<link href="../../css/style.css?v=4.1.0" rel="stylesheet">
		<link href="../../css/plugins/pageMe/pageMe.css" rel="stylesheet" />
		<link href="../../css/plugins/progressbar/mprogress.css" rel="stylesheet" />
		<link href="../../css/plugins/progressbar/style.css" rel="stylesheet" />
	</head>

	<body class="gray-bg">
		<div class="wrapper wrapper-content animated fadeInRight">

			<div class="ibox float-e-margins">
				<div class="ibox-title">
					<h5>user_article管理模块</h5>
				</div>
				<div class="ibox-content">
					<div class="row row-lg">
						<div class="clearfix hidden-xs"></div>
						<div class="col-sm-12">
							<!-- Example Checkbox Select -->
							<div class="example-wrap">

								<!-- 查询区域 -->
								<div id="queryModel">
											<input type="text" v-model="id" placeholder="主键id" style="margin-top: 10px"/>&nbsp;
											<input type="text" v-model="userId" placeholder="用户主键id" style="margin-top: 10px"/>&nbsp;
											<input type="text" v-model="articleId" placeholder="文章主键id" style="margin-top: 10px"/>&nbsp;
											<input type="text" v-model="rewardAmount" placeholder="打赏金额" style="margin-top: 10px"/>&nbsp;
											<input type="text" v-model="createBy" placeholder="创建人id" style="margin-top: 10px"/>&nbsp;
											<input type="text" v-model="createTime" placeholder="创建时间" style="margin-top: 10px"/>&nbsp;
											<input type="text" v-model="updateBy" placeholder="更新人id" style="margin-top: 10px"/>&nbsp;
											<input type="text" v-model="updateTime" placeholder="更新时间" style="margin-top: 10px"/>&nbsp;
											<input type="text" v-model="deleted" placeholder="是否删除（1：已删除，0：未删除）" style="margin-top: 10px"/>&nbsp;
									<button type="button" class="btn btn-primary btn-sm" @click="queryInfo()">查询</button>&nbsp;
									<button type="button" class="btn btn-primary btn-sm" @click="exportExcel()">导出excel</button>
								</div>
								<!-- 查询区域 end-->

								<!-- 添加数据区域 -->
								<div style="text-align: right;">
									<button type="button" class="btn btn-success btn-sm" onclick="addMsg()" style="margin: 8px">添加数据</button>
								</div>

								<!-- 查询结果表格显示区域 -->
								<div id="newsContent" class="table-responsive" style="overflow: scroll;" v-cloak>
									<table class="table table-hover table-bordered text-nowrap">
										<tr>
													<th>操作</th>
													<th>主键id</th>
													<th>用户主键id</th>
													<th>文章主键id</th>
													<th>打赏金额/元</th>
													<th>创建人id</th>
													<th>创建时间</th>
													<th>更新人id</th>
													<th>更新时间</th>
													<th>是否删除（1：已删除，0：未删除）</th>
										</tr>
										<tbody id="dataTable">
											<tr v-for="data in result">
												<td>
													 <button type="button" class="btn btn-info btn-sm" @click="upMsg(data.userId,data.articleId,'/userArticle/select')">更新</button>&nbsp;
													 <button type="button" class="btn btn-danger btn-sm" @click="delMsg(data.userId,data.articleId,'/userArticle/delete')">删除</button>&nbsp;
												</td>
												<td>{{data.id}}</td>
												<td>{{data.userId}}</td>
												<td>{{data.articleId}}</td>
												<td>{{data.rewardAmount}}</td>
												<td>{{data.createBy}}</td>
												<td>{{data.createTime}}</td>
												<td>{{data.updateBy}}</td>
												<td>{{data.updateTime}}</td>
												<td>{{data.deleted}}</td>
											</tr>
										</tbody>
									</table>
									<div id="pageID" class="page_div"></div>
								</div>
								<!-- 查询结果表格显示区域 end-->
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

		<!-- 修改模态框 -->
		<div class="modal fade" id="updateModal" tabindex="-1" role="dialog" aria-labelledby="updateModalLabel">
			<div class="modal-dialog" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close">
							<span aria-hidden="true">&times;</span>
						</button>
						<h4 class="modal-title" id="updateModalLabel">修改信息</h4>
					</div>
					<div class="modal-body" id="updateModalBody">
						<form>
									<div class="form-group">
										<label for="id-attr" class="control-label">id:</label>
										<input type="text" class="form-control" id="id-attr" v-model="id"/>
									</div>
									<div class="form-group">
										<label for="userId-attr" class="control-label">user_id:</label>
										<input type="text" class="form-control" id="userId-attr" v-model="userId"/>
									</div>
									<div class="form-group">
										<label for="articleId-attr" class="control-label">article_id:</label>
										<input type="text" class="form-control" id="articleId-attr" v-model="articleId"/>
									</div>
									<div class="form-group">
										<label for="rewardAmount-attr" class="control-label">reward_amount:</label>
										<input type="text" class="form-control" id="rewardAmount-attr" v-model="rewardAmount"/>
									</div>
									<div class="form-group">
										<label for="createBy-attr" class="control-label">create_by:</label>
										<input type="text" class="form-control" id="createBy-attr" v-model="createBy"/>
									</div>
									<div class="form-group">
										<label for="createTime-attr" class="control-label">create_time:</label>
										<input type="text" class="form-control" id="createTime-attr" v-model="createTime"/>
									</div>
									<div class="form-group">
										<label for="updateBy-attr" class="control-label">update_by:</label>
										<input type="text" class="form-control" id="updateBy-attr" v-model="updateBy"/>
									</div>
									<div class="form-group">
										<label for="updateTime-attr" class="control-label">update_time:</label>
										<input type="text" class="form-control" id="updateTime-attr" v-model="updateTime"/>
									</div>
									<div class="form-group">
										<label for="deleted-attr" class="control-label">deleted:</label>
										<input type="text" class="form-control" id="deleted-attr" v-model="deleted"/>
									</div>
									<div class="form-group">
										<input type="hidden" class="form-control" id="userId-attr" v-model="userId"/>
									</div>
									<div class="form-group">
										<input type="hidden" class="form-control" id="articleId-attr" v-model="articleId"/>
									</div>
						</form>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-primary" @click="confirmUp()">确认</button>
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					</div>
				</div>
			</div>
		</div>
	
		<!-- 添加模态框 -->
		<div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="addModalLabel">
			<div class="modal-dialog" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close">
							<span aria-hidden="true">&times;</span>
						</button>
						<h4 class="modal-title" id="addModalLabel">添加信息</h4>
					</div>
					<div class="modal-body" id="addModalBody">
						<form>
									<div class="form-group">
										<label for="id-insert" class="control-label">id:</label>
										<input type="text" class="form-control" id="id-insert" v-model="id"/>
									</div>
									<div class="form-group">
										<label for="userId-insert" class="control-label">user_id:</label>
										<input type="text" class="form-control" id="userId-insert" v-model="userId"/>
									</div>
									<div class="form-group">
										<label for="articleId-insert" class="control-label">article_id:</label>
										<input type="text" class="form-control" id="articleId-insert" v-model="articleId"/>
									</div>
									<div class="form-group">
										<label for="rewardAmount-insert" class="control-label">reward_amount:</label>
										<input type="text" class="form-control" id="rewardAmount-insert" v-model="rewardAmount"/>
									</div>
									<div class="form-group">
										<label for="createBy-insert" class="control-label">create_by:</label>
										<input type="text" class="form-control" id="createBy-insert" v-model="createBy"/>
									</div>
									<div class="form-group">
										<label for="createTime-insert" class="control-label">create_time:</label>
										<input type="text" class="form-control" id="createTime-insert" v-model="createTime"/>
									</div>
									<div class="form-group">
										<label for="updateBy-insert" class="control-label">update_by:</label>
										<input type="text" class="form-control" id="updateBy-insert" v-model="updateBy"/>
									</div>
									<div class="form-group">
										<label for="updateTime-insert" class="control-label">update_time:</label>
										<input type="text" class="form-control" id="updateTime-insert" v-model="updateTime"/>
									</div>
									<div class="form-group">
										<label for="deleted-insert" class="control-label">deleted:</label>
										<input type="text" class="form-control" id="deleted-insert" v-model="deleted"/>
									</div>
						</form>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-primary" @click="confirmAdd()">确认</button>
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					</div>
				</div>
			</div>
		</div>

		<!-- 全局js -->
		<script src="../../js/jquery.min.js?v=2.1.4"></script>
		<script src="../../js/bootstrap.min.js?v=3.3.6"></script>

		<!-- 自定义js -->
		<script src="../../js/content.js?v=1.0.0"></script>


		<!-- Bootstrap table -->
		<script src="../../js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
		<script src="../../js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
		<script src="../../js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>

		<!-- Peity -->
		<!-- <script src="../../js/demo/bootstrap-table-demo.js"></script> -->
		<script src="../../js/vue/vue.min.js"></script>
		<script src="../../js/util/ajaxFactory.js"></script>
		<script src="../../js/util/crudVueFactory.js"></script>
		<script src="../../js/util/pageMe.js"></script>
		<script src="../../js/config/config.js"></script>
		<script src="../../js/plugins/layer/layer.min.js"></script>
		<script src="../../js/plugins/progressbar/init-mprogress.js"></script>
		<script src="../../js/plugins/progressbar/mprogress.js"></script>

		<script>
			var currentPage = 1;
			var totalPage;
			var sqlMap = {};
			//排序的数据
			var orderData = [];
			var controllerPrefix = "userArticle";
			var methodName = "likeSelect";
	
			var queryVue = new Vue({
				el : '#queryModel',
				data : {
					id : '',
					userId : '',
					articleId : '',
					rewardAmount : '',
					createBy : '',
					createTime : '',
					updateBy : '',
					updateTime : '',
					deleted : ''
				},
				methods : {
					queryInfo : function() {
						sqlMap = {};
						sqlMap.id = this.id;
						sqlMap.userId = this.userId;
						sqlMap.articleId = this.articleId;
						sqlMap.rewardAmount = this.rewardAmount;
						sqlMap.createBy = this.createBy;
						sqlMap.createTime = this.createTime;
						sqlMap.updateBy = this.updateBy;
						sqlMap.updateTime = this.updateTime;
						sqlMap.deleted = this.deleted;
						currentPage = 1;
						orderData = [];
						$crud.getDataByCurrentPage();
					},
					exportExcel : function() {
	
						//显示进度条
						InitMprogress();
	
	                    var param = '';
	
	                    for (var key in sqlMap) {
                            if (sqlMap[key] != '') {
                                param += key + "=" + sqlMap[key] + "&";
                            }
	                    }
	
						window.location.href = basePath + "/" + controllerPrefix
								+ "/exportExcel?" + param;
						// 进度条消失
						setTimeout("MprogressEnd()", totalPage / 20 * 1000);
					}
				}
	
			});
	
			function makeResult(data) {
				for (var i = 0; i < data.length; i++) {
					if (data[i] == null) {
						data[i] = {};
						data[i]["id"] = "无";
						data[i]["userId"] = "无";
						data[i]["articleId"] = "无";
						data[i]["rewardAmount"] = "无";
						data[i]["createBy"] = "无";
						data[i]["createTime"] = "无";
						data[i]["updateBy"] = "无";
						data[i]["updateTime"] = "无";
						data[i]["deleted"] = "无";
					}
				}
			}
	
			var tableVue = new Vue({
				el : '#newsContent',
				data : {
					result : []
				},
				//created:
				mounted : function() {
					$crud.getDataByCurrentPage();
				},
				methods : {
	
					upMsg : function(userId, articleId, path) {
	
						$z.ajaxStrAndJson({
							url : basePath + path,
							data : {
								userId : userId,
								articleId : articleId
							},
							success : function(data) {
								$z.dealCommonResult(data, function () {
									data = data.result;
									upVue.userId = data[0]["userId"];
									upVue.articleId = data[0]["articleId"];
									upVue.id = data[0]["id"];
									upVue.userId = data[0]["userId"];
									upVue.articleId = data[0]["articleId"];
									upVue.rewardAmount = data[0]["rewardAmount"];
									upVue.createBy = data[0]["createBy"];
									upVue.createTime = data[0]["createTime"];
									upVue.updateBy = data[0]["updateBy"];
									upVue.updateTime = data[0]["updateTime"];
									upVue.deleted = data[0]["deleted"];
									$('#updateModal').modal('show');
								});
							}
						});
					},
					delMsg : function(userId, articleId, path) {
						layer.confirm("<em style='color:black'>" + '执行删除后将无法恢复，确定继续吗？' + "</em>", {
							icon: 3,
							offset: "200px",
							title: '温馨提示'
						}, function(index) {
							//do something 
							$z.ajaxStrAndJson({
								url: basePath + path,
								data: {
	                        		userId : userId,
	                        		articleId : articleId
								},
								success: function(data) {
									$z.dealCommonResult(data, function () {
										$crud.getDataByCurrentPage();
										layer.alert("<em style='color:black'>" + "删除成功！" + "</em>", {
											icon: 6,
											offset: "200px",
											title: '提示'
										});
									});
								}
							});
							layer.close(index);
						});
					}
				}
			});
	
			var upVue = new Vue({
				el : "#updateModal",
				data : {
					userId : '',
					articleId : '',
					id : '',
					userId : '',
					articleId : '',
					rewardAmount : '',
					createBy : '',
					createTime : '',
					updateBy : '',
					updateTime : '',
					deleted : ''
				},
				methods : {
					confirmUp : function() {
						$z.ajaxStrAndJson({
							url : basePath + "/" + controllerPrefix + "/update",
							data : {
								userId : this.userId,
								articleId : this.articleId,
								id : this.id,
								userId : this.userId,
								articleId : this.articleId,
								rewardAmount : this.rewardAmount,
								createBy : this.createBy,
								createTime : this.createTime,
								updateBy : this.updateBy,
								updateTime : this.updateTime,
								deleted : this.deleted
							},
							success : function(data) {
								$z.dealCommonResult(data, function () {
									layer.alert("<em style='color:black'>" + "更新成功！" + "</em>", {
										icon: 6,
										offset: "200px",
										title: '提示'
									});
									$('#updateModal').modal('hide');
									$crud.getDataByCurrentPage();
								});
	                            
							}
						});
					}
				}
			});
	
			function addMsg() {
				$('#addModal').modal('show');
			}
	
			var addVue = new Vue({
	
				el : "#addModal",
				data : {
					id : '',
					userId : '',
					articleId : '',
					rewardAmount : '',
					createBy : '',
					createTime : '',
					updateBy : '',
					updateTime : '',
					deleted : ''
				},
				methods : {
					confirmAdd : function() {
						$z.ajaxStrAndJson({
							url : basePath + "/" + controllerPrefix + "/add",
							data : {
								id : this.id,
								userId : this.userId,
								articleId : this.articleId,
								rewardAmount : this.rewardAmount,
								createBy : this.createBy,
								createTime : this.createTime,
								updateBy : this.updateBy,
								updateTime : this.updateTime,
								deleted : this.deleted
							},
							success : function(data) {
								$z.dealCommonResult(data, function () {
									layer.alert("<em style='color:black'>" + "添加成功！" + "</em>", {
										icon: 6,
										offset: "200px",
										title: '提示'
									});
									$('#addModal').modal('hide');
									//初始化
									sqlMap = {};
									currentPage = totalPage;
									orderData = [];
									$crud.getDataByCurrentPage();
								});
	                            
							}
						});
					}
				}
			});
		</script>
	</body>
</html>
